using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using System.Collections.Generic;
using FutureOpen.Web.Pages;
using FutureOpen.Core.func.sql;
using FutureOpen.Core.func.util;

public partial class controls_GroupCatList : System.Web.UI.UserControl
{
    private int cid;
    private PageBase pbase;
    protected void Page_Load(object sender, EventArgs e)
    {
        pbase = (PageBase)this.Page;
        pbase.PageInit();

        cid = pbase.catid;
        if (!Page.IsPostBack)
        {
            LoadCatGroups();
        }     
    }

    public void LoadCatGroups()
    {
        if (cid < 0)
        {
            cid = 0;
        }
       
        if (CatItem.index == null) CatItem.Init();      
      
        StringBuilder sb = new StringBuilder();
        CatItem items = CatItem.index[this.cid];

        foreach(CatItem citem in items.subitems.Values)
        {
            sb.Append("<li><span>"+CatItem.GetLink(citem) + "</span><br />");
            sb.Append("<span>");
            int i = 0;
            foreach(CatItem subitem in citem.subitems.Values)
            {
                if (i++ < 2)
                {
                    sb.Append(CatItem.GetLink(subitem) + "&nbsp;");
                }
                else
                {
                    sb.Append(StringUtil.EncodeNoDecURL("../test/Groups.aspx?catid=" + citem.cid, ".."));
                    break;
                }
            }
            sb.Append("</span>");			
			sb.Append("</li>");
        }
        this.ltContent.Text = sb.ToString();
    }
}                        